{% extends 'inventory/base.html' %}

{% block title %}会员详情 - {{ block.super }}{% endblock %}

{% block content %}
<div class="card mb-4">
    <div class="card-header">
        <h4 class="mb-0">会员信息</h4>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <p><strong>会员名：</strong>{{ member.user.username }}</p>
                <p><strong>手机号：</strong>{{ member.phone }}</p>
                <p><strong>会员等级：</strong>{{ member.level.name }}</p>
            </div>
            <div class="col-md-6">
                <p><strong>当前积分：</strong>{{ member.points }}</p>
                <p><strong>累计消费：</strong>¥{{ member.total_spend }}</p>
                <p><strong>注册时间：</strong>{{ member.created_at|date:"Y-m-d H:i" }}</p>
            </div>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h4 class="mb-0">消费记录</h4>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th>订单编号</th>
                        <th>消费金额</th>
                        <th>折扣金额</th>
                        <th>实付金额</th>
                        <th>获得积分</th>
                        <th>消费时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for sale in member.sale_set.all %}
                    <tr>
                        <td>#{{ sale.id }}</td>
                        <td>¥{{ sale.total_amount }}</td>
                        <td>¥{{ sale.discount_amount }}</td>
                        <td>¥{{ sale.final_amount }}</td>
                        <td>{{ sale.points_earned }}</td>
                        <td>{{ sale.created_at|date:"Y-m-d H:i" }}</td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="6" class="text-center">暂无消费记录</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}